package net.qhzw.vip.qiyu.service.impl;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.qhzw.vip.qiyu.entity.DtsBatteryStatus;
import net.qhzw.vip.qiyu.entity.DtsBatteryStatus;
import net.qhzw.vip.qiyu.handler.MyException;
import net.qhzw.vip.qiyu.mapper.DtsBatteryManageMapper;
import net.qhzw.vip.qiyu.mapper.DtsBatteryStatusMapper;
import net.qhzw.vip.qiyu.model.DtsBarManageSecondaryExcel;
import net.qhzw.vip.qiyu.service.DtsBatteryManageService;
import net.qhzw.vip.qiyu.service.DtsBatteryStatusService;
import net.qhzw.vip.qiyu.util.MyDateUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class DtsBatteryStatusImpl extends ServiceImpl<DtsBatteryStatusMapper, DtsBatteryStatus> implements DtsBatteryStatusService {


    @Override
    public Page<DtsBatteryStatus> findByPage(Page<DtsBatteryStatus> page, DtsBatteryStatus dtsBatteryStatus) {
        return page(page, new LambdaQueryWrapper<DtsBatteryStatus>()
                .eq( DtsBatteryStatus::getIsDelete, 0)
                .eq(dtsBatteryStatus != null && !StringUtils.isEmpty(dtsBatteryStatus.getId()),DtsBatteryStatus::getId,dtsBatteryStatus.getId())
        );
    }

    @Override
    public boolean addDtsBatteryManage(DtsBatteryStatus dtsBatteryStatus) {
        dtsBatteryStatus.setId(IdWorker.getId());
        dtsBatteryStatus.setIsDelete((byte) 0);

        //dtsBarManage.setCreateBy(SecurityUtils.getUserId());
        dtsBatteryStatus.setCreated(new Date());

        return  save(dtsBatteryStatus);

    }

    @Override
    public boolean updateDtsBatteryManage(DtsBatteryStatus dtsBatteryStatus) {
        dtsBatteryStatus.setCreated(new Date());
        return updateById(dtsBatteryStatus);
    }


}
